{% extends "djdb/internal_page.html" %}

{% load common_extras %}
{% load djdb_extras %}

{% block breadcrumbs %}
<a href="/">chipradio home</a> /
<a href="/djdb/">DJ Database home</a>
{% endblock %}

{% block content %}

{% block extrahead %}
<script type="text/javascript" 
    src="/media/common/js/jquery/jquery-1.3.1.js"></script>
<script type="text/javascript" 
    src="/media/common/js/jquery-autocomplete/jquery.autocomplete.js"></script>
<script type="text/javascript" 
    src="/media/djdb/js/djdb.js"></script>
<script type="text/javascript"
    src="/media/djdb/js/djdb_delete_review.js"></script>
<script type="text/javascript"
    src="/media/djdb/js/djdb_tags.js"></script>
<script type="text/javascript"
    src="/media/djdb/js/djdb_image_box.js"></script>
<script type="text/javascript"
    src="/media/djdb/js/djdb_edit_album.js"></script>
<script type="text/javascript"
    src="/media/djdb/js/djdb_edit_track.js"></script>
{% endblock %}

{% if album.pronunciation %}
<i>Pronunciation: {{ album.pronunciation }}</i>
{% endif %}

{% if has_category %}
<p>
  <h3 class="categories">Category:
{% for tag in album.current_tags %}
  {% if tag in album_categories %}
    <div class="track_{{ tag }}">{{ tag|replace:"/_/ "|capfirst }}</div>
  {% endif %}
{% endfor %}
  </h3>
</p>
{% endif %}

{% if msg %}
<div class="success">
{{ msg }}
</div>
{% endif %}

{% if error %}
<div class="warning">
{{ error }}
</div>
{% endif %}

{% if user.is_music_director %}
<div class="edit_album" style="display: none">
  <form action="{{ album.url }}" method="post">
    <table>
{{ album_form.as_table }}
    </table>
    <input type="submit" name="update_album" value="Update Album">
    <input class="edit_album" type="submit" name="cancel" value="Cancel">
  </form>
</div>
{% endif %}

{% if show_reviews %}
<h3>Reviews</h3>
  {% if album.reviews %}
    {% if show_review_link %}
<a href="/djdb/album/{{ album.album_id }}/new_review">Write another review</a> of this album.
    {% endif %}
    {% for doc in album.reviews %}
      {% if user.is_music_director or not doc.is_hidden %}
<p>
        {% if doc.is_hidden %}
<div style="background-color: #ffdddd">
<font color="#ff5555">This review is hidden.</font><br/>
        {% endif %}
<blockquote>
{{ doc.text|safe }}
</blockquote>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<small>--posted by
{% if doc.author %}
<a href="/djdb/user/{{ doc.author.key.id }}">{{ doc.author_display }}</a>
{% else %}
{{ doc.author_display }}
{% endif %}

on {{ doc.created_display|date:"F j, Y P" }}</small>
        {% if user.is_music_director %}
[ <a href="/djdb/album/{{ album.album_id }}/edit_review/{{ doc.key }}">Edit</a> 
          {% if doc.is_hidden %}
| <a href="/djdb/album/{{ album.album_id }}/unhide_review/{{ doc.key }}">Unhide</a>
          {% else %}
| <a href="/djdb/album/{{ album.album_id }}/hide_review/{{ doc.key }}">Hide</a>
          {% endif %}
| <a class="delete_review_{{ forloop.counter }}" href="/djdb/album/{{ album.album_id }}/delete_review/{{ doc.key }}">Delete</a> ]
        {% else %}
          {% ifequal user.key doc.author.key %}
[ <a href="/djdb/album/{{ album.album_id }}/edit_review/{{ doc.key }}">Edit</a> ]
          {% endifequal %}
        {% endif %}
        {% if user.is_music_director %}
  <div class="warning delete_review_{{ forloop.counter }}" style="display: none">
    <form action="/djdb/album/{{ album.album_id }}/delete_review" method="post">
      <input type="hidden" name="review_key" value="{{ doc.key }}"/>
      Are you sure:
      <input type="submit" name="confirm" value="Confirm"/>
      <input class="delete_review_{{ forloop.counter }}" type="submit" name="cancel" value="Cancel"/>
    </form>
  </div>
        {% endif %}
        {% if doc.is_hidden %}
</div>
        {% endif %}
</p>
      {% endif %}
    {% endfor %}
  {% else %}
    {% if show_review_link %}
No reviews yet!  You could be the first to
<a href="/djdb/album/{{ album.album_id }}/new_review">write a review</a> of this album.
    {% endif %}
  {% endif %}
{% endif %}

<h3>Album Tags</h3>
<table><tr><td>
<div class="tags" style="display: inline">
{% for tag in album.sorted_current_tags %}
  {% if tag not in album_categories %}
    <div class="tag">
{{ tag }}
        <img class="remove_tag" style="display: none" src="/media/common/img/remove.png" title="Remove tag"/>
    </div>
  {% endif %}
{% endfor %}
    <select class="tag" style="display: none">
        <option>-</option>
{% if user.is_music_director %}
        <option>Other</option>
{% endif %}
{% for tag in album_tags %}
        <option>{{ tag }}</option>
{% endfor %}
    </select>
    <input class="tag" style="display: none"/>
</div>
<img class="add_tag" src="/media/common/img/add.png" title="Add a new tag"/>
</td></tr></table>

<h3>Tracks</h3>
<form method="post" name="djdbTracksForm" action="update">
<p>
Select: <a id="select_all" href="">All</a>, 
        <a id="select_none" href="">None</a>, 
        <a id="select_explicit" href="">Explicit</a>, 
        <a id="select_recommended" href=" ">Recommended</a><br/>
Mark/Unmark selected as: <a id="mark_explicit" href="update">Explicit</a>, 
                         <a id="mark_recommended" href="update">Recommended</a>
</p>
<input type="hidden" name="mark_as"/>
<table>
  <tr>
    <td>
      <table><tr><td>
        <a class="album_cover" href="{{ album_cover_xl }}"><img src="{{ album_cover_m }}" width="50" height="50"/></a>
      </td></tr></table>
    </td>
    <td>
      <table>
{% for track in tracks %}
  {% if track.revoked %}
        <tr class="track_list revoked">
  {% else %}
        <tr class="track_list">
  {% endif %}
          <td>
            <input type="checkbox"
                   class="checkbox{% if track.is_explicit %} explicit{% endif %}{% if track.is_recommended %} recommended{% endif %}"
                   name="checkbox_{{ forloop.counter }}"/>
          </td>
          <td>
  {% if track.is_explicit %}
            <img height="16" width="16" src="/media/common/img/explicit_icon.png" title="Explicit lyrics"/>
  {% endif %}
  {% if track.is_recommended %}
            <img height="16" width="16" src="/media/common/img/recommended_icon.png" title="Recommended track"/>
  {% endif %}
          </td>
          <td>{{ track.track_num }}.</td>
          <td>{{ track.title }}
  {% if user.is_music_director %}
            <a href="" class="edit_track_{{ forloop.counter }}"><img src="/media/common/img/page_white_edit.png"/></a>
  {% endif %}
  {% if track.pronunciation %}
            <br/><i>Pronunciation: {{ track.pronunciation }}</i>
  {% endif %}
          </td>
  {% if album.is_compilation %}
    {% if track.track_artist %}
          <td>{{ track.track_artist }}</td>
    {% else %}
          <td><font color="red">No track artist</font></td>
    {% endif %}
  {% endif %}
          <td>{{ track.duration }}</td>
          <td><small>{{ track.bit_rate_kbps }} kbps</small></td>
          <td>
  {% for tag in track.sorted_current_tags %}
    {% ifnotequal tag 'explicit' %}
      {% ifnotequal tag 'recommended' %}
[{{tag}}]
      {% endifnotequal %}
    {% endifnotequal %}
  {% endfor %}
          </td>
          <td>
            <a class="send_to_playlist" href="/djdb/crate/send_to_playlist/{{ track.key }}"><img src="/media/common/img/play.png" alt="Send to Playlist" title="Send to Playlist"/></a>    
          </td>
          <td>
  {% ifincrate user track %}
            <a href="/djdb/crate/remove_item?response_page=album&item_key={{ track.key }}"><img src="/media/common/img/remove.png" alt="Remove Track from Crate" title="Remove Track from Crate"/></a>
  {% else %}
            <a href="/djdb/crate/add_item?response_page=album&item_key={{ track.key }}"><img src="/media/common/img/add.png" alt="Add Track to Crate" title="Add Track to Crate"/></a>
  {% endifincrate %}
          </td>
  {% if user.is_music_director %}
          <td>
    {% if not album.revoked %}
      {% if track.revoked %}
            <a href="/djdb/track/{{ track.key }}/unrevoke?response_page=album" title="Unrevoke track"> <img src="/media/common/img/unrevoke_icon.png" alt="Unevoke track"/></a>
      {% else %}
            <a href="/djdb/track/{{ track.key }}/revoke?response_page=album" title="Revoke track"> <img src="/media/common/img/revoke_icon.png" alt="Revoke track"/></a>
      {% endif %}
    {% endif %}
  {% endif %}
          </td>
        </tr>
  {% if user.is_music_director %}
        <tr>
          <td></td>
          <td></td>
          <td colspan="10" style="margin: 0">
            <div class="edit_track_{{ forloop.counter }}" style="display: none">
              <input type="hidden" name="track_key_{{ forloop.counter }}" value="{{ track.key }}"/>
              <table>
                <tr>
                  <td>Pronunciation:</td>
    {% if track.pronunciation %}
                  <td><input type="input" name="pronunciation_{{ forloop.counter }}" value="{{ track.pronunciation }}"/></td>
    {% else %}
                  <td><input type="input" name="pronunciation_{{ forloop.counter }}"/></td>
    {% endif %}
                </tr>
                <tr>
                  <td>Track artist:</td>
                  <td>
                    <input type="hidden" name="track_artist_key_{{ forloop.counter }}" value="{{ track.track_artist.key }}"/>
    {% if track.track_artist %}
                    <input type="input" name="track_artist_{{ forloop.counter }}" id="track_artist_key_{{ forloop.counter }}" value="{{ track.track_artist }}"/>
    {% else %}
                    <input type="input" name="track_artist_{{ forloop.counter }}" id="track_artist_key_{{ forloop.counter }}"/>
    {% endif %}<br/>
                    <i>You <b>must</b> select an artist from<br/>the autocomplete list.</i>
                  </td>
                </tr>
              </table>
              <input type="submit" name="update_track_{{ forloop.counter }}" value="Update Track"/>
              <input type="submit" class="edit_track_{{ forloop.counter }}" value="Cancel"/>
            </div>
          </td>
        </tr>
  {% endif %}
{% endfor %}
      </table>
    </td>
  </tr>
</table>
</form>

{% if album.reviews %}
<h3>Comments</h3>
  {% if album.comments %}
<a href="/djdb/album/{{ album.album_id }}/new_comment">Write another comment</a> about this album.
    {% for doc in album.comments %}
      {% if user.is_music_director or not doc.is_hidden %}
<p>
        {% if doc.is_hidden %}
<div style="background-color: #ffdddd">
<font color="#ff5555">This comment is hidden.</font><br/>
        {% endif %}
<blockquote>
{{ doc.text|safe }}
</blockquote>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<small>--posted by
{% if doc.author %}
<a href="/djdb/user/{{ doc.author.key.id }}">{{ doc.author }}</a>
{% else %}
{{ doc.author }}
{% endif %}
on {{ doc.created_display|date:"F j, Y P" }}</small>
        {% ifequal user.key doc.author.key %}
[ <a href="/djdb/album/{{ album.album_id }}/edit_comment/{{ doc.key }}">Edit</a>
        {% else %}
          {% if user.is_music_director %}
[ <a href="/djdb/album/{{ album.album_id }}/edit_comment/{{ doc.key }}">Edit</a> 
          {% endif %}    
        {% endifequal %}
        {% if user.is_music_director %}
          {% if doc.is_hidden %}
| <a href="/djdb/album/{{ album.album_id }}/unhide_comment/{{ doc.key }}">Unhide</a>
          {% else %}
| <a href="/djdb/album/{{ album.album_id }}/hide_comment/{{ doc.key }}">Hide</a>
          {% endif %}
| <a class="delete_comment_{{ forloop.counter }}" href="/djdb/album/{{ album.album_id }}/delete_comment/{{ doc.key }}">Delete</a>
        {% endif %}
]
        {% if user.is_music_director %}
  <div class="delete_comment_{{ forloop.counter }}" style="display: none">
    <br/>
    <form action="/djdb/album/{{ album.album_id }}/delete_comment" method="post">
      <input type="hidden" name="comment_key" value="{{ doc.key }}"/>
      Are you sure:
      <input type="submit" name="confirm" value="Confirm"/>
      <input class="delete_comment_{{ forloop.counter }}" type="submit" name="cancel" value="Cancel"/>
    </form>
  </div>
        {% endif %}
        {% if doc.is_hidden %}
</div>
        {% endif %}
</p>
      {% endif %}
    {% endfor %}
    <br/><br/><br/><br/><br/>
  {% else %}
No comments yet!  You could be the first to
<a href="/djdb/album/{{ album.album_id }}/new_comment">write a comment</a> about this album.
  {% endif %}
{% endif %}

{% endblock %}
